var request = null;
function createRequest() {
	try {
		request = new XMLHttpRequest();

	} catch (trymicrosoft) {
		try {
			request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (othermicrosoft) {
			try {
				request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (faild) {
				request = null;
			}
		}
	}
	if (request == null) {
		console.log("创建ajax对象失败。。。。。");
		alert("创建XMLHttpRequest请求失败");
	}
	console.log("创建ajax对象成功");
}

// 显示器材类别
function sendRequest(url, flag) {
	createRequest();

	request.open("GET", url, false);
	// 如果flag为false 则采用 网页方式显示，如果为true则采用alert方式显示
	if (flag == false) {
		request.onreadystatechange = doResponse;
	} else if (flag == true) {
		request.onreadystatechange = doAlert;
	}
    console.log("进入sendrequest......");
	request.send(null);
}
// 返回内容采用网页显示
function doResponse() {
	if (request.readyState == 4) {
		if (request.status == 200) {

			// document.getElementById("form1").innerHtml=request.responseText;
			var form1 = document.getElementById("form1");

			// 这样可以防止显示不出表格
			form1.innerHTML = request.responseText;

		}

	}

}

// 返回内容采用alert方式显示
function doAlert() {
	if (request.readyState == 4) {
		if (request.status == 200) {
			alert(request.responseText);
		}
	}
}
// 获取请求地址
function getAddress(mainUrl, id) {
	var url = mainUrl + "?";
	var obj = document.getElementById(id);
	// console.log(obj.baseURI);
	for ( var i = 0; i < obj.length - 1; i++) {
		url += obj[i].name + "=" + obj[i].value + "&";
		console.log(obj[i].name);

	}
	console.log("url=" + url);
	return url;

}
